/***********************************************************************************************************************************
 * Name:	Synonym.sql
 * Author:	Frank Figearo (frank.figearo@us.bbaaviation.com|frank@sqlnerd.me)
 * Summary:	Example of CREATE SYNONYM for linked servers.
 */
SET IMPLICIT_TRANSACTIONS OFF; IF 0 < @@TRANCOUNT ROLLBACK;
GO
DECLARE
@tsql_template NVARCHAR(MAX)= N'CREATE SYNONYM BasePOS FOR [?].POS.dbo.TransactionHeader',
@tsql_command NVARCHAR(MAX);

SET @tsql_command= REPLACE(@tsql_template,'?','SSI-MCO-POS01.BBAAviation.net')
execute (@tsql_command)

select top 100 * from BasePOS

DROP SYNONYM BasePOS
